import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SEntityInfo } from "../../../../../Message/BroadCast/SEntityInfo";
import { Cache } from "../../../cache/Cache";
import { SFightAttribute } from "../../../../../Message/Public/SFightAttribute";
//class PetExploreToolTip
    
    export  class PetExploreToolTip /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._labelArray = Language.getString(54541).split(",");
            this._valueTxtArray = [];
            this._attrVArray = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            var loc2=null;
            ObjCreate.createBg(0, 0, 170, 200, this, ImagesConst.ToolTipBg);
            var loc3=0;
            while (loc3 < this._labelArray.length) 
            {
                loc2 = this._labelArray[loc3] as string;
                ObjCreate.createTextField(loc2, 20, 10 + loc3 * 20, 80, 20, this, GlobalStyle.textFormat6);
                loc1 = ObjCreate.createTextField("", 85, 10 + loc3 * 20, 80, 20, this, GlobalStyle.textFormat6);
                this._valueTxtArray.push(loc1);
                ++loc3;
            }
            return;
        }

        public updateBySEntityInfo(arg1: SEntityInfo): void
        {
            if (arg1) 
            {
                (this._valueTxtArray[0] as Object /* flash.text.TextField */).text = arg1.life.toString();
                (this._valueTxtArray[1] as Object /* flash.text.TextField */).text = arg1.mana.toString();
                this.updateByFightAttribute(Cache.instance.petExplore.battlePetFightFightAttribute);
            }
            return;
        }

        public updateByFightAttribute(arg1: SFightAttribute): void
        {
            var loc1=null;
            this._attrVArray = [0, 0];
            if (arg1) 
            {
                this._attrVArray.push(arg1.physicalAttack);
                this._attrVArray.push(arg1.magicAttack);
                this._attrVArray.push(arg1.physicalDefense);
                this._attrVArray.push(arg1.magicDefense);
                this._attrVArray.push(arg1.hit);
                this._attrVArray.push(arg1.jouk);
                this._attrVArray.push(arg1.physicalCrit + arg1.magicCrit);
            }
            var loc2=2;
            while (loc2 < this._valueTxtArray.length) 
            {
                loc1 = this._valueTxtArray[loc2] as Object /* flash.text.TextField */;
                if (this._attrVArray[loc2]) 
                {
                    loc1.text = this._attrVArray[loc2].toString();
                }
                else 
                {
                    loc1.text = "0";
                }
                ++loc2;
            }
            return;
        }

        /* internal */ /* var */_labelArray: Array<any>;

        /* internal */ /* var */_valueTxtArray: Array<any>;

        /* internal */ /* var */_attrVArray: Array<any>;
    }
